package cn.njxzc.exercises;

import java.io.File;

public class DeleFiles {

	void delete(String filename){
	 File f=new File(filename);
	 if(!f.exists()){
		 System.out.println("文件或目录不存在！"+filename);
	 }
	 if (!f.canWrite()) {
		 System.out.println("文件或目录只读！"+filename);
		
	}
	 if(f.isDirectory()){
		 String[] filesStrings=f.list();
		 if(filesStrings.length>0){
			 System.out.println("目录不为空！"+filename);
		 }
	 if(f.delete()){
		 System.out.println("删除成功！");
	 }else {
		 System.out.println("删除失败！");
	}
	 
	 }
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
     String fn="d:\\ls";
     DeleFiles dFiles=new DeleFiles();
     dFiles.delete(fn);
	}

}
